package com.kujawnode.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kujawnode.constant.Constants;
import com.kujawnode.mapper.TActivityMapper;
import com.kujawnode.model.TActivityVO;
import com.kujawnode.query.ActivityQuery;
import com.kujawnode.query.BaseQuery;
import com.kujawnode.service.ActivityService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version 1.0
 * @Author kujaw
 * @Date 2025/7/17 12:56
 * @注释
 */
@Service
public class ActivityServiceImpl implements ActivityService {

    @Resource
    private TActivityMapper tActivityMapper;

    @Override
    public PageInfo<TActivityVO> getActivityByPage(Integer current, ActivityQuery activityQuery) {
        //1.设置PageHelper
        PageHelper.startPage(current, Constants.PAGE_SIZE);
        //2.查询
        List<TActivityVO> activityList = tActivityMapper.selectActivityByPage(
                activityQuery
        );
        //3.封装分页数据到PageInfo
        PageInfo<TActivityVO> activities = new PageInfo<>(activityList);
        return activities;
    }

}
